﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LS_DeliveryModeWebForm.aspx.cs" Inherits="Anke.SHManage.Web.Reports.LS_DeliveryModeWebForm" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><%=Title%></title>
    <script src="../Content/EasyUI/jquery.js"></script>
    <script src="../Content/EasyUI/jquery.easyui.js"></script>
    <script src="../Content/EasyUI/locale/easyui-lang-zh_CN.js"></script>
    <link href="../Content/EasyUI/themes/icon.css" rel="stylesheet" />
    <link href="../Content/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    <script src="../Scripts/jquery.AnkeExtend.js"></script>
    <script src="../Scripts/pinyin.js"></script>
    <script type="text/javascript">

        var str;
        //页面加载
        $(document).ready(function () {
            DisableBackspace();

            fillCombobox();
        });
        //根据登录人员取相应的物资分类
        //function init() {
        //    $.ajax({
        //        type: 'POST',
        //        url: "../IM/AllDictionary/GetMaterialTypeByUserInfoOther",
        //        dataType: "json",
        //        success: function (jsData) {
        //            str = jsData;
        //        }
        //    });
        //}
        function fillCombobox() {
            //出库单类型       
            $.EUIcombobox("#DeliveryType", {
                url: "../IM/AllDictionary/GetMSDictionaryInfo?TypeCode=MatertalOutType",
                valueField: 'ID',
                textField: 'Name',
                editable: false,
                panelHeight: 'auto',
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }]
            });
            //实际标识
            $.EUIcombobox("#ReceiverAmbulance", {
                url: "../CM/CarBasicInfo/getPlateByStationID?stationCode='-1'",
                valueField: 'AmbulanceCode',
                textField: 'PlateNumber',
                editable: true,
                OneOption: [{
                    AmbulanceCode: "",
                    PlateNumber: "--请选择--"
                }],
                filter: function (q, row) {
                    var opts = $('#ReceiverAmbulance').combobox('options');
                    return row[opts.textField].indexOf(q) > -1;
                }
            });
            //源仓库
            $.EUIcombobox("#SourceStorage", {
                url: "../IM/AllDictionary/GetStorageCombo",
                valueField: 'ID',
                textField: 'Name',
                editable: false,
                panelHeight: 'auto',
                datainfo: {},
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }]
            });
            //目标仓库
            $.EUIcomboboxTree("#TargetStorage", {
                url: "../IM/AllDictionary/GetAllStorage",//ajax后台取数据路径，返回的是json格式的数据
                OneOption: [{
                    id: "",
                    text: "--请选择--",
                }],
                onSelect: function (node) {
                    var t = $('#TargetStorage').combotree('tree');
                    var listnode = t.tree('getChildren', node.target);
                    if (listnode == null) {
                        $('#TStorageList').val(node.id);
                    } else {
                        var tSList = node.id;
                        for (var i = 0; i < listnode.length; i++) {
                            tSList = tSList + "," + listnode[i].id
                        }
                        $('#TStorageList').val(tSList);
                    }
                }
            });
            //物资分类         
            var urlstr = "../IM/AllDictionary/GetMaterialTypeByUserInfo";
            $.EUIcomboboxTree("#Classification", {
                url: urlstr,//ajax后台取数据路径，返回的是json格式的数据
                OneOption: [{
                    id: "",
                    text: "--请选择--",
                }],
                datainfo: {},
                onSelect: function (rec) {
                    //if (rec.id == "") {
                    //    //$("#MaterialID").val("");
                    //    //$("#MaterialTypeInfo").val("");
                    //    //$("#Material").combobox("setText","");
                    //    return;
                    //}
                    var urlstr3 = "../IM/AllDictionary/GetMaterial?mType=" + rec.id;
                    //$("#MaterialTypeInfo").val(rec.id);
                    $("#Material").combogrid({
                        prompt: '--请选择--',
                        url: urlstr3,
                        panelWidth: 320,
                        idField: 'ID',
                        textField: 'Name',
                        groupField: 'QRCode',
                        columns: [[
                            { field: 'MCode', title: '代码', width: 50, align: 'right' },
                            { field: 'Name', title: '名称', width: 100 },
                            { field: 'UnitName', title: '单位', width: 50 },
                            { field: 'Specification', title: '规格', width: 50, align: 'right' },
                            { field: 'RealPrice', title: '售价', width: 50 },
                            { field: 'Unit', title: '单位', width: 50, sortable: false, hidden: true }
                        ]],
                        fitColumns: true,
                        filter: function (inputText, row) {
                            var opts = $(this).combogrid('options');
                            if (row[opts.groupField] == inputText) {
                                return true;
                            } else if (row[opts.textField] == inputText) {
                                return true;
                            } else {
                                if (boolSearch) {
                                    boolSearch = false;
                                    searchBindMeterialbyName(urlstr3, inputText);
                                }
                            }
                        },
                        //小写拼音全拼搜索，首字母大写模糊查询 2018-10-17 dyq
                        filter: function (q, row) {
                            var opts = $(this).combogrid('options');
                            var text = row[opts.textField];//下拉的对应选项的汉字
                            var pyjp = pinyin.getCamelChars(text);//根据选项名字转换对应的拼音首字母并转换为大写
                            var pyqp = pinyin.getFullChars(text).toLowerCase();//拼音全拼备用
                            if (row[opts.textField].indexOf(q) > -1 || pyqp.indexOf(q.toLowerCase()) > -1) {
                                return true;
                            } if (row[opts.textField].indexOf(q) > -1 || pyjp.indexOf(q) > -1) {
                                return true
                            }
                        },
                        onChange: function (n, o) {
                            if (n == "") {
                                searchBindMeterialbyName(urlstr3, n);
                                //$("#MaterialID").val("");
                            }
                        },
                        onSelect: function (rec) {
                            var g = $("#Material").combogrid("grid");	// 获取数据表格对象
                            var r = g.datagrid('getSelected');	// 获取选择的行
                            // $("#MaterialID").val($('#Material').combobox('getValue'));
                        }
                    });
                    searchBindMeterialbyName(urlstr3, "");

                }

            });
            //物资名称 

            $.ajax({
                type: 'POST',
                url: "../IM/AllDictionary/GetMaterialTypeByUserInfoOther",
                dataType: "json",
                success: function (jsData) {
                    sss = jsData;
                    alert(sss);
                    var urlstr4 = "../IM/AllDictionary/GetMaterialLists?mType=" + sss;
                    $("#Material").combogrid({
                        prompt: '--请选择--',
                        url: urlstr4,
                        panelWidth: 320,
                        idField: 'ID',
                        textField: 'Name',
                        groupField: 'QRCode',
                        columns: [[
                             { field: 'MCode', title: '代码', width: 50, align: 'right' },
                             { field: 'Name', title: '名称', width: 100 },
                             { field: 'UnitName', title: '单位', width: 50 },
                             { field: 'Specification', title: '规格', width: 50, align: 'right' },
                             { field: 'RealPrice', title: '售价', width: 50 },
                             { field: 'Unit', title: '单位', width: 50, sortable: false, hidden: true }
                        ]],
                        fitColumns: true,
                        filter: function (inputText, row) {
                            var opts = $(this).combogrid('options');
                            if (row[opts.groupField] == inputText) {
                                return true;
                            } else if (row[opts.textField] == inputText) {
                                return true;
                            } else {
                                if (boolSearch) {
                                    boolSearch = false;
                                    searchBindMeterialbyName(urlstr4, inputText);
                                }
                            }
                        },
                        onChange: function (n, o) {
                            if (n == "") {
                                searchBindMeterialbyName(urlstr4, n);
                                //$("#Material").combobox('setValue',"");
                            }
                        },
                        onSelect: function (rec) {
                            var g = $("#Material").combogrid("grid");	// 获取数据表格对象
                            var r = g.datagrid('getSelected');	// 获取选择的行
                            //$('#Material').combobox('getValue');
                        }
                    });
                    searchBindMeterialbyName(urlstr4, "");
                }

            });





            function searchBindMeterialbyName(urinfo, keyWord) {
                $.ajax({
                    type: 'POST',
                    url: urinfo,
                    dataType: "json",
                    success: function (jsData) {
                        if (keyWord == "") {
                            $("#Material").combogrid("grid").datagrid("loadData", jsData);
                        } else {
                            for (var i = 0; i < jsData.length; i++) {
                                if (jsData[i].Name.indexOf(keyWord) < 0) {
                                    if (jsData[i].MCode.indexOf(keyWord) < 0) {
                                        if (jsData[i].PinYin.indexOf(keyWord) < 0) {
                                            jsData.remove(jsData[i]);
                                            i--;
                                        }
                                    }
                                }
                            }
                            $("#Material").combogrid("grid").datagrid("loadData", jsData);
                        }
                        boolSearch = true;
                    }
                });
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <table>
            <tr>
                <td>查询时间：</td>
                <td>
                    <asp:TextBox ID="StartDate" class="easyui-datetimebox" Style="width: 160px" runat="server" editable="false"></asp:TextBox>
                </td>
                <td style="text-align: center">至</td>
                <td>
                    <asp:TextBox ID="EndDate" class="easyui-datetimebox" Style="width: 160px" runat="server" editable="false"></asp:TextBox>
                </td>
                <td style="text-align: right">源仓库：</td>
                <td>
                    <asp:TextBox ID="SourceStorage" class="easyui-combobox" Style="width: 160px" runat="server"></asp:TextBox>
                </td>
                <td style="text-align: right">领取人(车)：</td>
                <td>
                    <asp:TextBox ID="ReceiverAmbulance" class="easyui-combobox" Style="width: 160px" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right">分类：</td>
                <td>
                    <asp:TextBox ID="Classification" class="easyui-combobox" Style="width: 160px" runat="server"></asp:TextBox>
                </td>
                <td style="text-align: right">物资：</td>
                <td>
                    <asp:TextBox ID="Material" class="easyui-combogrid" Style="width: 160px" runat="server"></asp:TextBox>
                </td>
                <td style="text-align: right">出库单号：</td>
                <td>
                    <asp:TextBox ID="DeliveryListCode" class="easyui-textbox" Style="width: 160px" runat="server"></asp:TextBox>
                </td>
                <td style="text-align: right">出库单类型：</td>
                <td>
                    <asp:TextBox ID="DeliveryType" class="easyui-combobox" Style="width: 160px" runat="server"></asp:TextBox>
                </td>     
            </tr>
            <tr>
                <td style="text-align: right">领取人：</td>
                <td>
                    <asp:TextBox ID="Receiver" class="easyui-textbox" Style="width: 160px" runat="server"></asp:TextBox>
                </td>
                <td style="text-align: right">经办人：</td>
                <td>
                    <asp:TextBox ID="Operator" class="easyui-textbox" Style="width: 160px" runat="server"></asp:TextBox>
                </td>
                <td style="text-align: right" id="storehouse" runat="server">目标仓库：</td>
                <td>
                    <asp:TextBox ID="TargetStorage" class="easyui-combotree" Style="width: 160px" runat="server"></asp:TextBox>
                </td>
                <td> 
                    <asp:Button ID="btnSearch" runat="server" Text="查 询" OnClick="btnSearch_Click" />
                </td>
            </tr>
        </table>
        <div style="background-color: #fafafa; border-left: 1px solid scrollbar; overflow: hidden; height: 100%;">
            <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="100%" Height="100%"  SizeToReportContent="True">
            </rsweb:ReportViewer>
        </div>
    </form>
</body>
</html>
